import request from '@/utils/request'

// 新增用户
export function addUser(data) {
  return request({
    url: '/platform-web/sysUser/add',
    method: 'post',
    data: data
  })
}

// 获取用户列表
export function getUserList(parms) {
  return request({
    url: '/platform-web/sysUser/query',
    method: 'get',
    params: parms
  })
}
// 编辑用户
export function editUser(data) {
  return request({
    url: '/platform-web/sysUser/update',
    method: 'put',
    data: data
  })
}
// 重置密码
export function restPass(id) {
  return request({
    url: '/platform-web/sysUser/restPass/' + id,
    method: 'put'
  })
}
// 删除用户
export function deleteUser(id) {
  return request({
    url: '/platform-web/sysUser/delete/' + id,
    method: 'delete'
  })
}

// 修改密码
export function updatePass(parms) {
  return request({
    url: '/platform-web/sysUser/updatePass',
    method: 'put',
    params: parms
  })
}

// 编辑用户详情
export function editUserInfo(parms) {
  return request({
    url: '/platform-web/sysUser/updateUserInfo',
    method: 'put',
    // data发送的是json param
    data: parms
  })
}

// 修改邮箱
export function updateEmail(parms) {
  return request({
    url: '/platform-web/sysUser/updateEmail',
    method: 'put',
    params: parms
  })
}

// 发送邮箱验证码
export function sendMailCode(email) {
  // 如果这种形式 都是走的默认
  return request({
    url: '/platform-web/sysUser/sendMailCode/' + email,
    method: 'put'
  })
}

// 上传头像
export function uploadAvatar(parms) {
  const config = {
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  }
  return request.post(
    '/platform-web/sysUser/uploadAvatar',
    parms,
    config
  )
}
